package com.zkkz.boot.campus.controller;


import com.zkkz.boot.campus.mapper.UserMapper;
import com.zkkz.boot.campus.pojo.ResultResp;
import com.zkkz.boot.campus.pojo.UserDo;
import com.zkkz.boot.campus.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author tsj
 * @date 2023/9/12 14:33
 * @description
 */
@Slf4j
@RefreshScope
@RestController
@RequestMapping("/web")
@Api(tags = "web后台")
public class WebController {

    @Resource
    private UserMapper userMapper;
    @Resource
    private UserServiceImpl userService;

    @Value("${value}")
    private String value;
    @Value("${mybatis-plus.mapper-locations}")
    private String mybatisPlus;
    @ApiOperation(value = "测试网关")
    @PostMapping("/testGateway")
    public void testGateway(/*@RequestBody @Validated ParentUserIdReq req*/) {
        System.out.println("测试网关成功!");
    }

    @ApiOperation(value = "测试restTemplate")
    @PostMapping("/testRemoteCallCampusTest")
    public ResultResp testRemoteCallCampusTest(/*@RequestBody @Validated ParentUserIdReq req*/) {
        UserDo build = UserDo.builder().username("谭声俊测试template名称").password("123456").build();
        log.info("单独打包运行时需要报没有加载主类那就在pom.xml文件中添加<mainClass>com.zkkz.boot.campus.CampusApplication</mainClass>");
        log.info("可以用来做MySQL读取压力测试");
        return userService.testRemoteCallCampusTest();
    }
    @ApiOperation("上传minio文件")
    @PostMapping("/uploadMinioFile")
    public ResultResp uploadMinioFile(@RequestPart(value = "file",required = true) MultipartFile file) throws Exception {
        return userService.uploadMinioFile(file);
    }
}
